import { useState } from "react";
import MyForm from "@/components/form";
import MyPagination from "@/components/pagination";
import MyTable from "@/components/table";
import FeedbackModal from "@/components/modal/feedback";

import { Button, FormInstance, message, Spin ,Table,Modal} from "antd";
import { getFeedBack, reply } from "@/api";

import "./index.less";

const columns = (del: any) => [
  {
    title: "姓名",
    dataIndex: "name",
    key: "name",
  },

  {
    title: "年龄",
    dataIndex: "age",
    key: "age",
  },

  {
    title: "住址",
    dataIndex: "address",
    key: "address",
  },
  {
    title: "电话",
    dataIndex: "phone",
    key: "phone",
  },
  {
    title: "操作",
    dataIndex: "id",
    key: "id",
    render: (v, r) => {
      return (
        <Button type="link" onClick={() => del(v)}>
          删除
        </Button>
      );
    },
  },
];

const initFormItems = [
  {
    itemType: "select",
    itemProps: {
      name: "name",
    },
    childProps: {
      placeholder: "搜索地区",
    },
  },
  {
    itemType: "input",
    itemProps: {
      name: "context",
    },
    childProps: {
      placeholder: "搜索内容",
    },
  },
];
export default function FeedBack() {

  const [dataSource, setDataSource] = useState({
    records: [],
    pageNumber: 1,
    pageSize: 10,
    totalRow: 0,
  });


  const deleteFun = (id: any) => {
    Modal.warning({
      title: "删除",
      content: "确认删除吗？删除后不可还原。",
      onOk: () => {
        // employeeUserRemove(id).then((data) => {
        //   if (data?.status) {
        //     message.success("删除成功");
        //     getEmployeeList({
        //       pageNumber: dataSource.pageNumber,
        //       pageSize: dataSource.pageSize,
        //     });
        //   } else {
        //     message.error(data?.msg || data?.code || "请求错误");
        //   }
        // });
      },
    });
  };

  return (
    <div className="feedback-container">
      <Table
        dataSource={dataSource.records || []}
        columns={columns(deleteFun)}
        pagination={{
          total: dataSource.totalRow,
          onChange: (pageNo, pageSize) => {
            setDataSource({ ...dataSource, pageNumber: pageNo, pageSize });
          },
        }}
      />
    </div>
  );
}
FeedBack.route = {
  [MENU_PATH]: "/statistics/feedback",
};
